/**
 * 项目名称: Topic_222.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月07日10时44分13秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    int countNodes(TreeNode* root) {
        if(!root)return 0;
        queue<TreeNode *>q;
        q.push(root);
        int cnt = 0;
        while (!q.empty()){
            TreeNode * p =q.front();
            q.pop();
            if(p->left)q.push(p->left);
            if(p->right)q.push(p->right);
            cnt++;
        }
        return cnt;
    }
};

int main() {

    return 0;
}
